// https://www.luogu.com.cn/problem/P3372
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
int rad(); // read int
const int max_size = 5 + 100;
const int maxn = 5 + 1e5;

int n, q;
ll a[maxn], c[2][maxn]; // c[0][i] for d[i], c[1][i] for i * d[i]

void update(int i, int x, int dep) {
    while (i <= n) {
        c[dep][i] += x;
        i += i & -i;
    }
}

ll pre(int i, int dep) {
    ll ret = 0;
    while (i >= 1) {
        ret += c[dep][i];
        i -= i & -i;
    }
    return ret;
}

int main() {
    n = rad(), q = rad();
    rf(i, n) {
        a[i] = rad();
        update(i, a[i] - a[i - 1], 0);
        update(i, i * (a[i] - a[i - 1]), 1);
    }
    while (q--) {
        int op = rad();
        if (op == 1) {
            int l = rad(), r = rad(), k = rad();
            update(l, k, 0), update(r + 1, -k, 0);
            update(l, l * k, 1), update(r + 1, -(r + 1) * k, 1);
        } else if (op == 2) {
            int l = rad(), r = rad();
            printf("%lld\n", pre(r, 0) * (r + 1) - pre(r, 1) - (pre(l - 1, 0) * l - pre(l - 1, 1)));
        }
    }
}

int rad() {
    int back = 0, ch = 0, posi = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        posi = ch ^ '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return posi ? back : -back;
}